package com.ebelter.myehc.ui.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ebelter.myehc.R;


/**
 * Created by ZCQ on 2017/12/1
 * 组合控件6 不知道怎么起名字了 还是按序号来吧
 */

public class CombinView9 extends LinearLayout{
    public CombinView9(Context context) {
        this(context,null);
    }




    public CombinView9(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }




    public CombinView9(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CombinView9);
        if (typedArray != null) {
            title1 = typedArray.getString(R.styleable.CombinView9_title1);
            drawable = typedArray.getDrawable(R.styleable.CombinView9_image1);
            typedArray.recycle();
        }

        initView(getContext());


    }

    private String title1;
    private Drawable drawable;

    private TextView title1_tv;
    //private TextView title2_tv;
    private ImageView image1_iv;



    private void initView(Context context) {
        View view =  View.inflate(context, R.layout.cb9_layout, this);//把那个布局当做是自己的孩子

        title1_tv = view.findViewById(R.id.cb9_title1_tv);
        image1_iv = view.findViewById(R.id.cb9_image1_iv);

        setTitle1(title1);

        image1_iv.setImageDrawable(drawable);


    }






    public void setTitle1(String title1){
        this.title1=title1;
        if (title1_tv!=null){
            title1_tv.setText(this.title1);
        }
    }

    public void setImage1(int res){
        if (image1_iv!=null){
            image1_iv.setImageResource(res);
        }
    }

}
